import { getlist, setSchedule, getSchedule } from '../../api/msbd'

export default {
    namespaced: true,
    state: {
        data: [],
        currentPage: 0,
        total: 0,
        status: false,
        bdids: []
    },
    mutations: {
        SET_GETLIST(state, data) {
            //合并两个或多个数组
            //state.data = state.data.concat(data)
            if (state.currentPage == 0) {
                state.data = data.data
            } else {
                state.data.push(...data.data);
            }
            // console.log(state.data);
            state.total = data.total
        },
        SET_CURRENTPAGE(state, page) {
            state.currentPage = page
        },
        SET_DETAILCOMMENT(state, status) {
            state.status = status
        },
        SET_SCHUDULE(state, bdids) {
            state.bdids = bdids.data
        }
    },
    actions: {
        async getList({ commit, state }) {
            let r = await getlist({
                currentPage: state.currentPage
            })
            commit('SET_GETLIST', r)
        },
        async setSchedule({ }, obj) {
            // console.log(obj);
            await setSchedule(obj)
        },
        async getSchedule({ commit }, uid) {
            let r = await getSchedule({ uid });
            commit('SET_SCHUDULE', r)
            console.log(r)
        }
    },
    getters: {
    }
}